<?php

use App\Http\Controllers\Applet\Cart\CartController;
use App\Http\Controllers\Applet\Notice\SysMessageController;
use App\Http\Controllers\Applet\Order\ShopOrderController;
use App\Http\Controllers\Applet\Order\SponsorOrderController;
use App\Http\Controllers\Applet\Other\AliYunCloudController;
use App\Http\Controllers\Applet\Other\AreaController;
use App\Http\Controllers\Applet\Other\SettingController;
use App\Http\Controllers\Applet\Payment\PaymentController;
use App\Http\Controllers\Applet\Shop\CategoryController as ShopCategoryController;
use App\Http\Controllers\Applet\Shop\ShopGoodsController;
use App\Http\Controllers\Applet\Sponsor\CategoryController as SponsorCategoryController;
use App\Http\Controllers\Applet\Sponsor\SlaughterController;
use App\Http\Controllers\Applet\Sponsor\SponsorGoodsController;
use App\Http\Controllers\Applet\User\AddressController;
use App\Http\Controllers\Applet\User\UserController;
use Illuminate\Support\Facades\Route;


Route::group(['prefix' => 'user', 'namespace' => 'User'], function () {
    Route::post('sendVerifyCode', [UserController::class, 'sendVerifyCode']);                   // 发送短信验证码
    Route::post('register', [UserController::class, 'register']);                               // 注册
    Route::post('login', [UserController::class, 'login']);                                     // 登录
    Route::post('resetPassword', [UserController::class, 'resetPassword']);                     // 重置密码


    Route::group(['middleware' => 'appletAuth'], function () {
        Route::post('logout', [UserController::class, 'logout']);                                   // 退出登录
        Route::get('userInfo', [UserController::class, 'userInfo']);                                // 用户详情
        Route::get('orderTotal', [UserController::class, 'orderTotal']);                            // 订单总数列表
        Route::get('sponsorList', [UserController::class, 'sponsorList']);                          // 认养列表
        Route::get('sponsorInfo', [UserController::class, 'sponsorInfo']);                          // 认养详情
        Route::get('integralRecordsList', [UserController::class, 'integralRecordsList']);          // 积分记录列表
    });

    Route::group(['prefix' => 'address', 'middleware' => 'appletAuth'], function () {
        Route::get('list', [AddressController::class, 'list']);     // 我的地址列表
        Route::get('detail', [AddressController::class, 'detail']); // 地址详情

        Route::post('create', [AddressController::class, 'create']); // 添加地址
        Route::post('update', [AddressController::class, 'update']); // 更新地址
        Route::post('delete', [AddressController::class, 'delete']); // 删除地址
    });
});


// 认养模块
Route::group(['prefix' => 'sponsor', 'namespace' => 'Sponsor', 'middleware' => 'appletAuth'], function () {
    Route::get('category/list', [SponsorCategoryController::class, 'list']);                    // 分类列表
    Route::get('goods/list', [SponsorGoodsController::class, 'list']);                          // 商品列表
    Route::get('goods/recommendList', [SponsorGoodsController::class, 'recommendList']);        // 推荐商品列表
    Route::get('goods/detail', [SponsorGoodsController::class, 'detail']);                      // 商品详情

    Route::post('slaughter/create', [SlaughterController::class, 'create']); // 申请宰杀
});

// 商城
Route::group(['prefix' => 'shop', 'namespace' => 'Shop'], function () {
    Route::get('category/list', [ShopCategoryController::class, 'list']);   // 分类列表
    Route::get('goods/list', [ShopGoodsController::class, 'list']);         // 商品列表
    Route::get('goods/detail', [ShopGoodsController::class, 'detail']);     // 商品详情
});

// 购物车
Route::group(['prefix' => 'cart', 'namespace' => 'Cart', 'middleware' => 'appletAuth'], function () {
    Route::get('list', [CartController::class, 'list']);                   // 购物车列表
    Route::get('totalQuantity', [CartController::class, 'totalQuantity']); // 购物车总数量

    Route::post('create', [CartController::class, 'create']); // 添加购物车
    Route::post('update', [CartController::class, 'update']); // 修改购物车
    Route::post('delete', [CartController::class, 'delete']); // 删除购物车

});

Route::group(['prefix' => 'order', 'namespace' => 'Order', 'middleware' => 'appletAuth'], function () {
    // 认养订单
    Route::group(['prefix' => 'sponsor'], function () {
        Route::post('create', [SponsorOrderController::class, 'create']);         // 创建认养订单
        Route::post('cartCreate', [SponsorOrderController::class, 'cartCreate']); // 购物车创建认养订单
        Route::post('cancel', [SponsorOrderController::class, 'cancel']);         // 取消订单
        Route::post('delete', [SponsorOrderController::class, 'delete']);         // 删除订单

        Route::get('list', [SponsorOrderController::class, 'list']);     // 认养订单列表
        Route::get('detail', [SponsorOrderController::class, 'detail']); // 认养订单详情
    });

    // 商城订单
    Route::group(['prefix' => 'shop'], function () {
        Route::post('create', [ShopOrderController::class, 'create']);            // 创建商城订单
        Route::post('cartCreate', [ShopOrderController::class, 'cartCreate']);    // 购物车创建认养订单
        Route::post('cancel', [ShopOrderController::class, 'cancel']);            // 取消订单
        Route::post('delete', [ShopOrderController::class, 'delete']);            // 删除订单

        Route::post('confirm', [ShopOrderController::class, 'confirm']); // 确认收货

        Route::get('list', [ShopOrderController::class, 'list']);     // 订单列表
        Route::get('detail', [ShopOrderController::class, 'detail']); // 订单详情
    });

});

Route::group(['prefix' => 'payment', 'namespace' => 'Payment', 'middleware' => 'appletAuth'], function () {

    Route::get('payParams', [PaymentController::class, 'payParams']); // 支付参数
});

Route::group(['prefix' => 'other', 'namespace' => 'Other'], function () {

    Route::group(['prefix' => 'area'], function () {
        Route::get('list', [AreaController::class, 'list']); // 省市区地址列表
    });

    // 阿里云cloud
    Route::group(['prefix' => 'aliYunCloud'], function () {
        Route::get('getTemporaryVouchers', [AliYunCloudController::class, 'getTemporaryVouchers']); // 获取临时凭证
    });

    Route::group(['prefix' => 'setting'], function () {
        Route::get('sponsorSwitch', [SettingController::class, 'sponsorSwitch']);
    });
});

// 公告通知
Route::group(['prefix' => 'notice', 'namespace' => 'notice'], function () {
    Route::get('/sysMessage/list', [SysMessageController::class, 'list']); // 公告消息列表
});
